package string;

import java.util.Random;
import java.util.Scanner;

public class StringDemo02 {
    public static void main(String[] args) {
        //1.设计一个方法接受整形数组，返回对应位数的随机验证码
        System.out.println(creaeCode(6));
    }
    public static String creaeCode(int i){
        String code = "";
        String data = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random r  = new Random();
        for (int j = 0; j < i; j++) {
            int index = r.nextInt(data.length());
            code += data.charAt(index);
        }
        return code;
    }
}
